//
//  UIImage+MJ.m
//  新浪微博
//
//  Created by apple on 13-10-26.
//  Copyright (c) 2013年 itcast. All rights reserved.
//

#import "UIImage+MJ.h"

#define iPhone5 ([UIScreen mainScreen].bounds.size.height == 568)

@implementation UIImage (MJ)
#pragma mark 加载全屏的图片
+ (UIImage *)fullscrennImage:(NSString *)imgName
{
    if (iPhone5) {
        NSString *ext = [imgName pathExtension];
        imgName = [imgName stringByDeletingPathExtension];
        imgName = [imgName stringByAppendingString:@"-568h@2x"];
        imgName = [imgName stringByAppendingPathExtension:ext];
    }
    return [self imageNamed:imgName];
}

+ (UIImage*)imageFromView:(UIView*)view{
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, YES, view.layer.contentsScale);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

@end
